package cn.springcloud.fix.es.web.controller;

import cn.springcloud.fix.es.web.request.*;
import cn.springcloud.fix.es.web.response.*;
import cn.springcloud.fix.es.web.service.CartItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/cartItem")
public class CartItemController {

    @Autowired
    private CartItemService cartItemService;

    @PostMapping("/add")
    public AddCartItemResponse add(@Validated @RequestBody AddCartItemRequest request, HttpServletRequest httpServletRequest) {
        return cartItemService.add(request, httpServletRequest);
    }

    @PostMapping("/update")
    public UpdateCartItemResponse update(@Validated @RequestBody UpdateCartItemRequest request, HttpServletRequest httpServletRequest) {
        return cartItemService.update(request, httpServletRequest);
    }

    @PostMapping("/delete")
    public DeleteCartItemResponse delete(@Validated @RequestBody DeleteCartItemRequest request, HttpServletRequest httpServletRequest) {
        return cartItemService.delete(request, httpServletRequest);
    }
}
